using RichFrame;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace RichFrame.UIFrame
{
    public class UIFormManager : MonoSingleton<UIFormManager>
    {
        public Dictionary<string, UIFormBase> forms = new Dictionary<string, UIFormBase>();
        public Transform UIRoot;
        public Transform PopupUIRoot;
        public Transform HideOtherUIRoot;
        // Start is called before the first frame update
        void Start()
        {

        }

        // Update is called once per frame
        void Update()
        {

        }


        public void ShowForm(string formName)
        {
            forms[formName].Show();
        }

        public void HideForm(string formName)
        {
            forms[formName].Hide();
        }

        public GameObject CreateUIForm(UIFormBase uIForm)
        {
            Transform root;
            switch (uIForm.showType)
            {
                case UIFormBase.ShowType.Normal:
                    root = UIRoot;
                    break;
                case UIFormBase.ShowType.Popup:
                    root = PopupUIRoot;
                    break;
                case UIFormBase.ShowType.HideOther:
                    root = HideOtherUIRoot;
                    break;
                default:
                    root = UIRoot;
                    break;
            }
            return GameObject.Instantiate(AssetsManager.Instance.LoadAsset<GameObject>(uIForm.assetPath), root);
        }
    }
}
